<?php
Raise::load('core.RaiseObject');
Raise::load('core.collection.RaiseTypedCollection');

/**
 * RaisePostbackFeedback class
 * A handler that handles postback errors
 *
 * @author Sam-Mauris Yong / hellclanner at live dot com
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package phpraise.core.postback
 * @since 1.2
 */
class RaiseFieldFeedback extends RaiseObject {
    
    /**
     * Name of the postback field
     * @var string
     */
    private $field;

    /**
     * Value of the postback field
     * @var string
     */
    private $value;

    /**
     * The list of exceptions
     * @var RaiseTypedCollection
     */
    private $exceptions;

    /**
     * Creates a postback field feedback entry
     * @param string $field The field name
     * @param string $value The value of the field
     */
    public function __construct($field, $value) {
        $this->exceptions = new RaiseTypedCollection('RaisePostbackException');
        $this->field($field);
        $this->value($value);
    }

    /**
     * Get or set the field name
     * @param string $f (optional) Set the field name
     * @return string
     */
    public function field($f = null){
        if(func_num_args() == 1){
            $this->field = $f;
        }
        return $this->field;
    }

    /**
     * Get or set the value of the field
     * @param string $v (optional) Set the field value
     * @return string
     */
    public function value($v = null){
        if(func_num_args() == 1){
            $this->value = $v;
        }
        return $this->value;
    }

    /**
     * Get the list of exceptions associated with this field
     * @return RaiseTypedCollection
     */
    public function exceptions(){
        return $this->exceptions;
    }


}